
//
//  LNConstInline.h
//  LNDevelopExample
//
//  Created by wwww on 2018/9/5.
//  Copyright © 2018年 淘发现1iOS. All rights reserved.
//

#ifndef LNConstInline_h
#define LNConstInline_h

/// 网络图片的占位图片
static inline UIImage *LNWebImagePlaceholder(){
    return [UIImage imageNamed:@"placeholder_image"];
}

/// 网络头像
static inline UIImage *LNWebAvatarImagePlaceholder(){
    return [UIImage imageNamed:@"DefaultProfileHead_66x66"];
}

/// 适配
static inline CGFloat LNPxConvertToPt(CGFloat px){
    return ceil(px * [UIScreen mainScreen].bounds.size.width/414.0f);
}


/// 辅助方法 创建一个文件夹
static inline void LNCreateDirectoryAtPath(NSString *path){
    BOOL isDir = NO;
    BOOL isExist = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
    if (isExist) {
        if (!isDir) {
            [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
            [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
        }
    } else {
        [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }
}
/// 微信重要数据备份的文件夹路径，通过NSFileManager来访问
static inline NSString *LNWeChatDocDirPath(){
    return [LNDocumentDirectory stringByAppendingPathComponent:LN_WECHAT_DOC_NAME];
}
/// 通过NSFileManager来获取指定重要数据的路径
static inline NSString *LNFilePathFromWeChatDoc(NSString *filename){
    NSString *docPath = LNWeChatDocDirPath();
    LNCreateDirectoryAtPath(docPath);
    return [docPath stringByAppendingPathComponent:filename];
}

/// 微信轻量数据备份的文件夹路径，通过NSFileManager来访问
static inline NSString *LNWeChatCacheDirPath(){
    return [LNCachesDirectory stringByAppendingPathComponent:LN_WECHAT_CACHE_NAME];
}
/// 通过NSFileManager来访问 获取指定轻量数据的路径
static inline NSString *LNFilePathFromWeChatCache(NSString *filename){
    NSString *cachePath = LNWeChatCacheDirPath();
    LNCreateDirectoryAtPath(cachePath);
    return [cachePath stringByAppendingPathComponent:filename];
}



#endif /* LNConstInline_h */

